require 'time'

class Numeric
  def squared
    self * self
  end
end

class Movie
  include Comparable
  include Enumerable
  
  attr_reader :name
  attr_reader :showtime
  
  def initialize(name,showtime)
    @name = name
    if showtime.is_a?(Time)
      @showtime = showtime
    elsif showtime.is_a?(String)
      @showtime = Time.parse(showtime)
    else
      raise ArgumentError
    end
  end
  
  def name_and_showtime
    msg = @showtime.strftime("%H%M") < Time.now.strftime("%H%M") ? "already started" : "next show"
    "#{@name}: #{msg} at #{@showtime.strftime("%I:%M %p")}"
  end
  
  def <=>(other)
    @showtime <=> other.showtime
  end
  
end

movies = []
movies << Movie.new("Orphan", Time.parse("1:00 pm"))
movies << Movie.new("Orphan", Time.parse("4:05 pm"))
movies << Movie.new("Orphan", Time.parse("7:00 pm"))
movies << Movie.new("GI Joe", Time.parse("1:05 pm"))
movies << Movie.new("GI Joe", Time.parse("4:30 pm"))
movies << Movie.new("GI Joe", Time.parse("6:50 pm"))
movies << Movie.new("Rocky Horror", Time.parse("12:00 am"))
movies << Movie.new("District 9", Time.parse("11:00 am"))
movies << Movie.new("District 9", Time.parse("3:00 pm"))
